const baseUrl = 'http://localhost:8888'
// const baseUrl = 'http://localhost:8888/api'
const request = (url = '', data = {}, type = 'POST') => {
	return new Promise((resolve, reject) => {
		uni.request({
			method: type,
			url: baseUrl + url,
			data,
			header: {
				// 'content-type': 'application/x-www-form-urlencoded', //表单格式
				// 'content-type': 'application/json', //uniapp默认json格式
				'token': 'abcdefghijklmnopqrstuvwxyz-0123456789'
			},
			dataType: 'json'
		})
		.then(response => {
			let [err, res] = response
			resolve(res.data)
			// resolve(response)
		})
		.catch(error => {
			let [err, res] = error
			reject(err)
			// reject(error)
		})
	})
}

export default request